﻿using System.Windows;
using PSE.Deployment.Engine.Enums;
using PSE.Deployment.SetupBase.Parameter.Enums;

namespace PSE.Deployment.SetupBase.UI
{
    public partial class UpdateInformation : BaseWindow
    {
        public UpdateInformation()
        {
            this.InitializeComponent();

            imageHotFix.Visibility = SetupMainFactory.GetInstance().Parameter.SetupMode == SetupMode.HotFix ? Visibility.Visible : Visibility.Collapsed;
            imageServicePack.Visibility = SetupMainFactory.GetInstance().Parameter.SetupMode == SetupMode.ServicePack ? Visibility.Visible : Visibility.Collapsed;
            txtTitle.Text = "Instalação do " + SetupMainFactory.GetInstance().Parameter.SetupConfiguration.SystemInfo.UpdateInfo.Name;
            lstInformation.ItemsSource = SetupMainFactory.GetInstance().Parameter.SetupConfiguration.SystemInfo.UpdateInfo.Descriptions;
            txtLabel.Content = string.Format("Este {0} instala as seguintes correções:", SetupMainFactory.GetInstance().Parameter.SetupMode.ToString());
        }

        private void btnInstall_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationAction = StepNavigationAction.Next;
            this.Close(false);
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationAction = StepNavigationAction.Cancel;
            this.Close(false);
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            if (NavigationAction != StepNavigationAction.Next)
            {
                this.NavigationAction = StepNavigationAction.Cancel;
            }

            base.OnClosing(e);
        }
    }
}
